package com.zjj.wangluo.lianxi.tcp02;

import java.io.IOException;
import java.io.PrintWriter;
import java.net.Socket;
import java.util.Scanner;
/**
 * @author zhoujunjie
 * @desc TODO
 * @date
 *
 * 需求2：服务端接收多条消息，客户端发送多条消息
 */
public class TCPClient {

    public static void main(String[] args) {
        System.out.println("------------客户端-------------");
        Socket socket = null;
        PrintWriter pw = null;
        try {
            //1.创建客户端，连接服务器
            socket = new Socket("" , 8888);
            //2.写消息
            pw = new PrintWriter(socket.getOutputStream());
            Scanner sc = new Scanner(System.in);
            while (true) {
                System.out.println("客户端写：");
                String s = sc.nextLine();
                pw.println(s);
                pw.flush();
                if (s.equals("886")) {
                    break;
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
